#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
	for (int i = 0; i <= 100000; i++)
	{
		int n = i;
		int count = 1;
		while (n > 9)
		{
			count++;
			n /= 10;
		}
		int m = i;
		int sum = 0;
		while (m)
		{
			sum += (int)pow(m % 10, count);
			m /= 10;
		}
		if (i == sum)
		{
			printf("%d", i);
			printf("\n");

		}
	}
	return 0;
}